package com.maltys.controller;

import com.maltys.domain.entity.User;
import com.maltys.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author malty
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/registry")
    public User registry(@RequestBody User user) {
        return userService.registerUser(user);
    }

    @PostMapping("/login")
    public String login(@RequestBody User user) {
        return userService.login(user);
    }

    @GetMapping("/info")
    public User userInfo(@RequestParam("name") String userName) {
        return userService.queryByUserName(userName);
    }
}
